package cn.passlink.www.Utils;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@Slf4j
public class ReqDataCheck {
//检查json字段Key是否正确或存在
public static boolean ReqDataCheckKeys(Map<String, Object> requestData, String[] keys) {
    final int MAX_VALUE_LENGTH = 10000;
    final int MAX_KEYS = 20;

    // 检查字段个数
    if (requestData.size() != keys.length || requestData.size() > MAX_KEYS) {
        return false;
    }
    // 检查字段是否存在并且对应的值是否符合要求
    for (String field : keys) {
        if (!requestData.containsKey(field)) {
            return false;
        }
        // 检查字段对应的值长度
        Object value = requestData.get(field);
        if (value.toString().length() > MAX_VALUE_LENGTH) {
            return false;
        }
    }
    return true;
}


}


